﻿using System;
using System.ComponentModel;
using System.Drawing;
using System.Drawing.Design;
using System.Xml;
using System.Xml.Serialization;
using Glider.Common.Objects;

namespace AdvancedMap
{

    public enum IconSource
    {
        [XmlEnumAttribute(Name = "Draw Triangles")]
        DrawTriangles,
        [XmlEnumAttribute(Name = "Use Icons")]
        UseIcons
    }


    public class AMSettings : XmlSerializable
    {
        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For internal use at this time."),
         DisplayNameAttribute("Name")]
        public string name { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For internal use at this time."),
         DisplayNameAttribute("Debug Flag")]
        public bool debug { get; set; }

        [BrowsableAttribute(true),
        CategoryAttribute("zzAdmin"),
        DescriptionAttribute("For internal use at this time."),
        DisplayNameAttribute("Scale")]
        public double scale { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For internal use at this time."),
         DisplayNameAttribute("Opacity")]
        public double opacity { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For internal use at this time."),
         DisplayNameAttribute("Use Log File")]
        public bool loggingStatus { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Keeps the map on top."),
         DisplayNameAttribute("Window Keep on Top")]
        public bool onTop { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For internal use at this time."),
         DisplayNameAttribute("Window Top X")]
        public int clientX { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For internal use at this time."),
         DisplayNameAttribute("Window Top Y")]
        public int clientY { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Not used at this time"),
         DisplayNameAttribute("Window Size: Width")]
        public int clientWidth { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Not used at this time"),
         DisplayNameAttribute("Window Size: Height")]
        public int clientHeight { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For debugging/fun purposes"),
         DisplayNameAttribute("Label on Top")]
        public string labelTop { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For debugging/fun purposes"),
         DisplayNameAttribute("Label on Bottom")]
        public string labelBot { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For debugging/fun purposes.  If true, automatically turn on and off the filters based on the cycles designated."),
         DisplayNameAttribute("Cycle Filter")]
        public bool cycleFilter { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For debugging/fun purposes.  Number of cycles to turn off Filters"),
         DisplayNameAttribute("Filters off the n cycles")]
        public int cyclesFilterOff { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For debugging/fun purposes.  Number of cycles to turn on Filters"),
         DisplayNameAttribute("Filters on for n cycles")]
        public int cyclesFilterOn { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("For debugging/fun purposes.  Size of Circle displayed on map."),
         DisplayNameAttribute("Circle of Annihlation")]
        public int circleViewSize { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Color of Circle of Annihlation ;->  The circle displayed on the map."),
         DisplayNameAttribute("Color of CoA")]
        [XmlIgnore()]
        public Color colorViewCircle { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorViewCircle")]
        public string XmlColorViewCircle
        {
            get { return SerializeColor(colorViewCircle); }
            set { colorViewCircle = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Font used for Object Text."),
         DisplayNameAttribute("Font")]
        [XmlIgnore()]
        public Font FontText { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("FontText")]
        public XmlFont XmlFontText
        {
            get { return SerializeFont(FontText); }
            set { FontText = DeserializeFont(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Sound On/Off.  True is on, False is off"),
         DisplayNameAttribute("Sound On")]
        public bool playSound { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Special search string.  If the string matches the name of a unit, then display in special color."),
         DisplayNameAttribute("Special Search String")]
        public string specialSearchString { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Color of Special on the map."),
         DisplayNameAttribute("Color of Special")]
        [XmlIgnore()]
        public Color colorSpecial { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorSpecial")]
        public string XmlColorSpecial
        {
            get { return SerializeColor(colorSpecial); }
            set { colorMe = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Name of wave file to play for Special Search."),
         DisplayNameAttribute("Soundfile for Special Search"),
         PathEditor.OfdParamsAttribute("Wave Files (*.wav)|*.wav", "Select Sound File you wish to use"),
         EditorAttribute(typeof(PathEditor), typeof(UITypeEditor))]
        public string soundfileSpecial { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Source for icons. Use Icons or Hand Draw Triangles."),
         DisplayNameAttribute("Icon Source")]
        public IconSource sourceIcons { get; set; }


        [BrowsableAttribute(true),
         CategoryAttribute("Players"),
         DescriptionAttribute("If true, show yourself on the map."),
         DisplayNameAttribute("Show Me")]
        public bool showMe { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Players"),
         DescriptionAttribute("Color of me on the map."),
         DisplayNameAttribute("Color of Myself")]
        [XmlIgnore()]
        public Color colorMe { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorMe")]
        public string XmlColorType
        {
            get { return SerializeColor(colorMe); }
            set { colorMe = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("Players"),
         DescriptionAttribute("Display players that are friendly to your faction."),
         DisplayNameAttribute("Show Friends")]
        public bool showFriends { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Players"),
         DescriptionAttribute("Color of friends on the map."),
         DisplayNameAttribute("Color of Friends")]
        [XmlIgnore()]
        public Color colorFriends { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorFriends")]
        public string XmlColorFriends
        {
            get { return SerializeColor(colorFriends); }
            set { colorFriends = DeserializeColor(value); }
        }


        [BrowsableAttribute(true),
         CategoryAttribute("Players"),
         DescriptionAttribute("Name of wave file to play for players that are friendly to your faction."),
         DisplayNameAttribute("Soundfile for Friends"),
         PathEditor.OfdParamsAttribute("Wave Files (*.wav)|*.wav", "Select Sound File you wish to use"),
         EditorAttribute(typeof(PathEditor), typeof(UITypeEditor))]
        public string soundfileFriends { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Players"),
         DescriptionAttribute("Display players that are enemies."),
         DisplayNameAttribute("Show Enemies")]
        public bool showEnemies { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Players"),
         DescriptionAttribute("Color of Enemies on the map."),
         DisplayNameAttribute("Color of Enemies")]
        [XmlIgnore()]
        public Color colorEnemies { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorEnemies")]
        public string XmlColorEnemies
        {
            get { return SerializeColor(colorEnemies); }
            set { colorEnemies = DeserializeColor(value); }
        }


        [BrowsableAttribute(true),
         CategoryAttribute("Players"),
         DescriptionAttribute("Regex Expression to compare against player names."),
         DisplayNameAttribute("Filter for Players")]
        public string FilterPlayers { get; set; }
        
        [BrowsableAttribute(true),
         CategoryAttribute("Players"),
         DescriptionAttribute("Name of wave file to play for Players that are unfriendly to your faction."),
         DisplayNameAttribute("Soundfile for Enemies"),
         PathEditor.OfdParamsAttribute("Wave Files (*.wav)|*.wav", "Select Sound File you wish to use"),
         EditorAttribute(typeof(PathEditor), typeof(UITypeEditor))]
        public string soundfileEnemies { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Non-Player Characters"),
         DescriptionAttribute("If true, display Non-Player Characters"),
         DisplayNameAttribute("Show NPCs")]
        public bool showNPCs { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Non-Player Characters"),
         DescriptionAttribute("Color of NPCs on the map."),
         DisplayNameAttribute("Color of NPCs")]
        [XmlIgnore()]
        public Color colorNPCs { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorNPCs")]
        public string XmlColorNPCs
        {
            get { return SerializeColor(colorNPCs); }
            set { colorNPCs = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("Non-Player Characters"),
         DescriptionAttribute("Regex Expression to filter NPC names"),
         DisplayNameAttribute("Filter for NPCs")]
        public string FilterNPCs { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Non-Player Characters"),
        DescriptionAttribute("Name of wave file to play for NPCs."),
        DisplayNameAttribute("Soundfile for NPCs"),
        PathEditor.OfdParamsAttribute("Wave Files (*.wav)|*.wav", "Select Sound File you wish to use"),
        EditorAttribute(typeof(PathEditor), typeof(UITypeEditor))]
        public string soundfileNPCs { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Monsters"),
         DescriptionAttribute("Show Hostile Monsters. Hostile Monsters will initiate an attack."),
         DisplayNameAttribute("Show Hostiles")]
        public bool showHostiles { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Monsters"),
         DescriptionAttribute("Color of Hostile Monsters on the map."),
         DisplayNameAttribute("Color of Hostiles")]
        [XmlIgnore()]
        public Color colorHostiles { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorHostiles")]
        public string XmlColorHostiles
        {
            get { return SerializeColor(colorHostiles); }
            set { colorHostiles = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("Monsters"),
         DescriptionAttribute("Show Neutral Monsters. Neutral Monsters will respond to an attack."),
         DisplayNameAttribute("Show Neutrals")]
        public bool showNeutrals { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Monsters"),
         DescriptionAttribute("Color of Neutral Monsters on the map."),
         DisplayNameAttribute("Color of Neutrals")]
        [XmlIgnore()]
        public Color colorNeutrals { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorNeutrals")]
        public string XmlColorNeutrals
        {
            get { return SerializeColor(colorNeutrals); }
            set { colorNeutrals = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("Monsters"),
         DescriptionAttribute("Show Unknown Monsters. Monsters that haven't been classified with Glider, or don't have enough information available."),
         DisplayNameAttribute("Show Unknown")]
        public bool showUnknownMonsters { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Monsters"),
         DescriptionAttribute("Color of Unknown Monsters on the map."),
         DisplayNameAttribute("Color of Unknowns")]
        [XmlIgnore()]
        public Color colorUnknownMonsters { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorUnknownMonsters")]
        public string XmlColorUnknownMonsters
        {
            get { return SerializeColor(colorUnknownMonsters); }
            set { colorUnknownMonsters = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("Monsters"),
         DescriptionAttribute("Show Only Elite Monsters.  CAUTION:  You will only see elite monsters.  If your monsters aren't showing up, this could be the issue."),
         DisplayNameAttribute("Show Only Elite")]
        public bool showOnlyEliteMonsters { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Monsters"),
         DescriptionAttribute("Minimum Monster Level.  If value is negative, subtract from your current level.  Else use as minumum value.  (-3 for a level 20 player would show monsters >=17)."),
         DisplayNameAttribute("Monster Minimum Level")]
        public Int32 MonsterMinLvl { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Monsters"),
         DescriptionAttribute("Regex Expression to filter monster names"),
         DisplayNameAttribute("Filter for Monsters")]
        public string FilterMonsters { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Monsters"),
         DescriptionAttribute("Name of wave file to play for monsters."),
         DisplayNameAttribute("Soundfile for Monsters"),
         PathEditor.OfdParamsAttribute("Wave Files (*.wav)|*.wav", "Select Sound File you wish to use"),
         EditorAttribute(typeof(PathEditor), typeof(UITypeEditor))]
        public string soundfileMonsters { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Herbs"),
         DescriptionAttribute("If true, display herbs on map."),
         DisplayNameAttribute("Show Herbs")]
        public bool showHerbs { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Herbs"),
         DescriptionAttribute("Color of Herbs on the map."),
         DisplayNameAttribute("Color of Herbs")]
        [XmlIgnore()]
        public Color colorHerbs { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorHerbs")]
        public string XmlColorHerbs
        {
            get { return SerializeColor(colorHerbs); }
            set { colorHerbs = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("Herbs"),
         DescriptionAttribute("Regex Expression to filter Herb names"),
         DisplayNameAttribute("Filter for Herbs")]
        public string FilterHerbs { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Herbs"),
         DescriptionAttribute("Name of wave file to play for herbs."),
         DisplayNameAttribute("Soundfile for Herbs"),
         PathEditor.OfdParamsAttribute("Wave Files (*.wav)|*.wav", "Select Sound File you wish to use"),
         EditorAttribute(typeof(PathEditor), typeof(UITypeEditor))]
        public string soundfileHerbs { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Minerals"),
         DescriptionAttribute("If true, show minerals on map."),
         DisplayNameAttribute("Show Minerals")]
        public bool showMinerals { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Minerals"),
         DescriptionAttribute("Color of Minerals on the map."),
         DisplayNameAttribute("Color of Minerals")]
        [XmlIgnore()]
        public Color colorMinerals { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorMinerals")]
        public string XmlColorMinerals
        {
            get { return SerializeColor(colorMinerals); }
            set { colorMinerals = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("Minerals"),
         DescriptionAttribute("Regex Expression to filter mineral names"),
         DisplayNameAttribute("Filter for Minerals")]
        public string FilterMinerals { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Minerals"),
         DescriptionAttribute("Name of wave file to play for Minerals."),
         DisplayNameAttribute("Soundfile for Minerals"),
         PathEditor.OfdParamsAttribute("Wave Files (*.wav)|*.wav", "Select Sound File you wish to use"),
         EditorAttribute(typeof(PathEditor), typeof(UITypeEditor))]
        public string soundfileMinerals { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Treasure"),
         DescriptionAttribute("If true, show treasure on map."),
         DisplayNameAttribute("Show Treasure")]
        public bool showTreasure { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Treasure"),
         DescriptionAttribute("Color of Treasure on the map."),
         DisplayNameAttribute("Color of Treasure")]
        [XmlIgnore()]
        public Color colorTreasure { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorTreasure")]
        public string XmlColorTreasure
        {
            get { return SerializeColor(colorTreasure); }
            set { colorTreasure = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("Treasure"),
         DescriptionAttribute("Regex Expression to filter treasure."),
         DisplayNameAttribute("Filter for Treasure")]
        public string FilterTreasure { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Treasure"),
         DescriptionAttribute("Name of wave file to play for treasure."),
         DisplayNameAttribute("Soundfile for Treasure"),
         PathEditor.OfdParamsAttribute("Wave Files (*.wav)|*.wav", "Select Sound File you wish to use"),
         EditorAttribute(typeof(PathEditor), typeof(UITypeEditor))]
        public string soundfileTreasure { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Miscellaneous"),
         DescriptionAttribute("If true, show miscellaneous items on map."),
         DisplayNameAttribute("Show Misc Items")]
        public bool showMisc { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Miscellaneous"),
         DescriptionAttribute("Color of miscellaneous items on the map."),
         DisplayNameAttribute("Color of MiscItems")]
        [XmlIgnore()]
        public Color colorMisc { get; set; }

        [BrowsableAttribute(false)]
        [XmlElement("colorMisc")]
        public string XmlColorMisc
        {
            get { return SerializeColor(colorMisc); }
            set { colorMisc = DeserializeColor(value); }
        }

        [BrowsableAttribute(true),
         CategoryAttribute("Miscellaneous"),
         DescriptionAttribute("Regex Expression to filter miscellaneous items."),
         DisplayNameAttribute("Filter for Misc Items")]
        public string FilterMisc { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("Miscellaneous"),
         DescriptionAttribute("Name of wave file to play for miscellaneous items."),
         DisplayNameAttribute("Soundfile for Misc Items"),
         PathEditor.OfdParamsAttribute("Wave Files (*.wav)|*.wav", "Select Sound File you wish to use"),
         EditorAttribute(typeof(PathEditor), typeof(UITypeEditor))]
        public string soundfileMisc { get; set; }

        [BrowsableAttribute(false),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Not used at this time"),
         DisplayNameAttribute("Show Waypoints")]
        public bool showWaypoints { get; set; }

        [BrowsableAttribute(false),
         CategoryAttribute("Front Panel"),
         DescriptionAttribute("Not used at this time"),
         DisplayNameAttribute("Show Names")]
        public bool showNames { get; set; }

        [BrowsableAttribute(false),
         CategoryAttribute("Front Panel"),
         DescriptionAttribute("Not used at this time"),
         DisplayNameAttribute("Show Class")]
        public bool showClass { get; set; }

        [BrowsableAttribute(false),
         CategoryAttribute("Front Panel"),
         DescriptionAttribute("Not used at this time"),
         DisplayNameAttribute("Show Health")]
        public bool showHealth { get; set; }

        [BrowsableAttribute(true),
         CategoryAttribute("zzAdmin"),
         DescriptionAttribute("Amount of Time to sleep between refreshing the map.  1000 = 1 second"),
         DisplayNameAttribute("Refresh Time")]
        public Int32 ThreadThrottle { get; set; }

        [BrowsableAttribute(false),
         CategoryAttribute("Front Panel"),
         DescriptionAttribute("Not used at this time"),
         DisplayNameAttribute("Filter State")]
        public bool useFilters { get; set; }

        public AMSettings()
        {
            name = "(default)";
            debug = false;
            scale = 1;
            opacity = 1;
            loggingStatus = true;
            onTop = true;
            clientX = 100;
            clientY = 100;
            clientWidth = 300;
            clientHeight = 300;
            circleViewSize = 50;
            colorViewCircle = Color.White;
            specialSearchString = "";
            colorSpecial = Color.Black;
            FontText = new Font("Verdana", (float)6.5);
            soundfileSpecial = "";
            sourceIcons = IconSource.DrawTriangles;
            showMe = true;
            colorMe = Color.White;
            labelBot = "";
            labelTop = "";
            showFriends = true;
            colorFriends = Color.Blue;
            soundfileFriends = "";
            showEnemies = true;
            colorEnemies = Color.HotPink;
            FilterPlayers = "";
            soundfileEnemies = "";
            showNPCs = true;
            colorNPCs = Color.MediumSpringGreen;
            FilterNPCs = "";
            soundfileNPCs = "";
            showHostiles = true;
            colorHostiles = Color.LightSalmon;
            showNeutrals = true;
            colorNeutrals = Color.Yellow;
            showUnknownMonsters = true;
            colorUnknownMonsters = Color.MediumVioletRed;
            showOnlyEliteMonsters = false;
            MonsterMinLvl = 0;
            FilterMonsters = "";
            soundfileMonsters = "";
            showHerbs = true;
            colorHerbs = Color.LightGreen;
            FilterHerbs = "";
            soundfileHerbs = "";
            showMinerals = true;
            colorMinerals = Color.PeachPuff;
            FilterMinerals = "";
            soundfileMinerals = "";
            showTreasure = true;
            colorTreasure = Color.Gold;
            FilterTreasure = "";
            soundfileTreasure = "";
            showMisc = true;
            colorMisc = Color.LightSkyBlue;
            FilterMisc = "";
            soundfileMisc = "";
            showWaypoints = true;
            showNames = true;
            showClass = true;
            showHealth = true;
            ThreadThrottle = 120;
            useFilters = false;
            cycleFilter = false;
            cyclesFilterOff = 150;
            cyclesFilterOn = 150;

        }

        public void Dump()
        {
            String dumpinfo;

            dumpinfo = DumperLib.Dumper.DumpObject(this, 5);

            GContext.Main.Log(dumpinfo);
        }
    }

}
